package StudyCode.summary.utf;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class WriteUTF8File {

	public static void main(String[] args) throws Exception {
		writeUTF8(new File("E:/Copy/test1.txt"), "www.tah1986.com", true);
		System.out.println("以UTF8编码追加文件成功");
	}

	public static void writeUTF8(File file, String text,
	                             boolean isAppend) throws Exception {
		FileOutputStream fos = new FileOutputStream(file, isAppend);
		Writer out = new OutputStreamWriter(fos, "UTF-8");
		out.write(text);
		out.flush();
		out.close();
	}
}
